package com.hapzxb.provider.controller;

import com.hapzxb.provider.bean.Department;
import com.hapzxb.provider.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/provider/department")
public class DepartmentController {
    @Autowired
    private DepartmentService service;

    @PostMapping("/save")
    public boolean saveHandle(@RequestBody Department department){
        department.setDbase("test");
        return service.saveDepartment(department);
    }

    @PostMapping("/del/{id}")
    public boolean delHandle(@PathVariable("id") int id){
        return service.removeDepartment(id);
    }

    @PostMapping("/update")
    public boolean updateHandle(@RequestBody Department department){
        department.setDbase("test");
        return service.modifyDepart(department);
    }

    @PostMapping("/get/{id}")
    public Department getHandle(@PathVariable("id") int id){
        return service.getDepartmentById(id);
    }

    @PostMapping("/list")
    public List<Department> listHandle(){
        return service.listAllDepartment();
    }
}
